<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>opennars: nars.storage.Distributor.Distributor</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">opennars
   &#160;<span id="projectnumber">1.5.5</span>
   </div>
   <div id="projectbrief">1.5-ish</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="../../namespaces.html"><span>Packages</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d2/d34/classnars_1_1storage_1_1Distributor_a9eba330bb6cf9a23584f10d0c469f8c0.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="contents">
<a class="anchor" id="a9eba330bb6cf9a23584f10d0c469f8c0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">nars.storage.Distributor.Distributor </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>range</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>For any number N &lt; range, there is N+1 copies of it in the array, distributed as evenly as possible. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">range</td><td>Range of valid numbers </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="../../d9/d44/Distributor_8java_source.html#l00040">40</a> of file <a class="el" href="../../d9/d44/Distributor_8java_source.html">Distributor.java</a>.</p>

<p>References <a class="el" href="../../d9/d44/Distributor_8java_source.html#l00031">nars.storage.Distributor.capacity</a>.</p>
<div class="fragment"><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;                                  {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        <span class="keywordtype">int</span> index, rank, time;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;        <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee.html#a54e7d3b3a28e67d224addc4c359400ee">capacity</a> = (range * (range + 1)) / 2;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3.html#a9cc2b32bdbc2bc304d2caa4bef6783f3">order</a> = <span class="keyword">new</span> <span class="keywordtype">int</span>[<a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee.html#a54e7d3b3a28e67d224addc4c359400ee">capacity</a>];</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;        <span class="keywordflow">for</span> (index = 0; index &lt; <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee.html#a54e7d3b3a28e67d224addc4c359400ee">capacity</a>; index++) {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;            <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3.html#a9cc2b32bdbc2bc304d2caa4bef6783f3">order</a>[index] = -1;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        }</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        <span class="keywordflow">for</span> (rank = range; rank &gt; 0; rank--) {</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;            <span class="keywordflow">for</span> (time = 0; time &lt; rank; time++) {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;                index = ((capacity / rank) + index) % <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee.html#a54e7d3b3a28e67d224addc4c359400ee">capacity</a>;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                <span class="keywordflow">while</span> (<a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3.html#a9cc2b32bdbc2bc304d2caa4bef6783f3">order</a>[index] &gt;= 0) {</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                    index = (index + 1) % capacity;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;                }</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;                <a class="code" href="../../d2/d34/classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3.html#a9cc2b32bdbc2bc304d2caa4bef6783f3">order</a>[index] = rank - 1;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;            }</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        }</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    }</div>
<div class="ttc" id="classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3_html_a9cc2b32bdbc2bc304d2caa4bef6783f3"><div class="ttname"><a href="../../d2/d34/classnars_1_1storage_1_1Distributor_a9cc2b32bdbc2bc304d2caa4bef6783f3.html#a9cc2b32bdbc2bc304d2caa4bef6783f3">nars.storage.Distributor.order</a></div><div class="ttdeci">int order[]</div><div class="ttdoc">Shuffled sequence of index numbers. </div><div class="ttdef"><b>Definition:</b> <a href="../../d9/d44/Distributor_8java_source.html#l00029">Distributor.java:29</a></div></div>
<div class="ttc" id="classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee_html_a54e7d3b3a28e67d224addc4c359400ee"><div class="ttname"><a href="../../d2/d34/classnars_1_1storage_1_1Distributor_a54e7d3b3a28e67d224addc4c359400ee.html#a54e7d3b3a28e67d224addc4c359400ee">nars.storage.Distributor.capacity</a></div><div class="ttdeci">int capacity</div><div class="ttdoc">Capacity of the array. </div><div class="ttdef"><b>Definition:</b> <a href="../../d9/d44/Distributor_8java_source.html#l00031">Distributor.java:31</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../d7/d81/namespacenars.html">nars</a></li><li class="navelem"><a class="el" href="../../de/ddc/namespacenars_1_1storage.html">storage</a></li><li class="navelem"><a class="el" href="../../d2/d34/classnars_1_1storage_1_1Distributor.html">Distributor</a></li>
    <li class="footer">Generated on Sun Jan 10 2016 18:03:59 for opennars by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
  </ul>
</div>
</body>
</html>
